<%@page import="com.util.JobPriviledgeUtil"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="com.pojo.job.pa.PAMenu" %>
<%@ page import="com.pojo.job.pa.PAJobPriviledge" %>
<%@page import="com.pojo.basic.Module"%>
<%@page import="com.pojo.basic.SALM"%>
<%@page import="com.pojo.basic.DEPT"%>
<%@page import="com.pojo.basic.ModuleUsers"%>
<%@page import="java.util.List"%>
<%@ include file="/default.jsp"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	PAMenu pamenu  = (PAMenu)request.getAttribute("pamenu");
	List<DEPT> depts  = (List<DEPT>)request.getAttribute("depts");
	List<SALM> salms  = (List<SALM>)request.getAttribute("salms");
	List<PAJobPriviledge> pajobpriviledges  = (List<PAJobPriviledge>)request.getAttribute("pajobpriviledges");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>表單設置</title>
<link rel="stylesheet" href="/Sunlike/extjs/resources/css/ext-all.css" type="text/css"></link>
<link rel="stylesheet" href="/Sunlike/css/toolbar.css" type="text/css"></link>
<link rel="stylesheet" href="/Sunlike/css/common.css" type="text/css"></link>
<script type="text/javascript" src="/Sunlike/extjs/adapter/ext/ext-base-debug.js"></script>
<script type="text/javascript" src="/Sunlike/extjs/ext-all-debug.js"></script>
<script type="text/javascript"  src="/Sunlike/js/Setting/toolbar.js"></script>
<style type="text/css">
<!--
a{text-decoration:none;color:black;};
-->
</style>
<script type="text/javascript">
//存储
function sava()
{
	var objs  = Ext.query(".checkall");
	var menu = Ext.getDom("menuid");
	var lists  = "";
	for(var i = 0 ; i < objs.length ;i++){
		var new_priviledge = Ext.getDom("new_"+objs[i].value);
		var remove_priviledge = Ext.getDom("remove_"+objs[i].value);
		var sava_priviledge = Ext.getDom("sava_"+objs[i].value);
		var modify_priviledge = Ext.getDom("modify_"+objs[i].value);
		var view_priviledge = Ext.getDom("view_"+objs[i].value);
		var privacy_priviledge = Ext.getDom("privacy_"+objs[i].value);
		var temp_new = new_priviledge.checked==true ?"1":"0" ;
		var temp_remove = remove_priviledge.checked==true ?"1":"0" ;
		var temp_sava = sava_priviledge.checked==true ?"1":"0" ;
		var temp_modify = modify_priviledge.checked==true ?"1":"0" ;
		var temp_view = view_priviledge.checked==true ?"1":"0" ;
		var temp_privacy= privacy_priviledge.checked==true ?"1":"0" ;
		var temp = objs[i].value + ";"+temp_new + ";" + temp_remove + ";"+ temp_sava + ";"+ temp_modify + ";"+ temp_view + ";"+ temp_privacy;
		lists = lists + temp + ":";
	}
	 Ext.MessageBox.show({
	        msg: '正在保存數據，請稍等...',
	        progressText: 'Saving...',
	        width:300,
	        wait:true,
	        waitConfig: {interval:200},
	        icon:'ext-mb-download'
	 });
    Ext.Ajax.request({
    	method:'POST',
    	url:'paJobAction.savaJobETPriviledgeData.action',
    	params: {datas:lists,id:menu.value},
    	success:function(request){
    		Ext.MessageBox.hide();
    		Ext.MessageBox.show({
    			 	title: '系統提示',
    		        msg: '數據保存成功！',
    		        width:300,
    		        buttons: Ext.MessageBox.OK,
    		        icon:Ext.MessageBox.INFO,
    		        fn:function(){
    		        	location.href = "paJobAction.initPAJobETPermissionData.action?id=<%= pamenu.getID() %>";
    		        }
    		});
    	},
    	failure:function(request){
    		Ext.MessageBox.hide();
    		 Ext.MessageBox.show({
    			 	title: '系統提示',
    		        msg: '數據保存失敗！',
    		        width:300,
    		        buttons: Ext.MessageBox.OK,
    		        icon:Ext.MessageBox.ERROR
    		     
    		 });
    	}
    });
   
}
</script>
</head>
<body>
<div id='toolbarspan'></div>
<input type="hidden" id="menuid" value="<%= pamenu.getID() %>">
<table width="100%" border="0" align="center">
<tr><td align="center"><SPAN> <b> <font  size="3">系統設定：表單設定：<%= pamenu.getNAME() %> :<font  color="blue">人員權限設定( E.T. )</font></font></b></SPAN> </td></tr>
</table>	

<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tbody><tr> 
      <td><span>&nbsp;&nbsp;&nbsp;&nbsp;<img src="/Sunlike/images/small_icon.bmp" width="9" height="9"><font   style="font-size:14px;font-family:MSYHBD;">人員權限設定( E.T.  )</font></span></td>
	  
      <td><div align="right">
      <span><img src="/Sunlike/images/arrow_r_r_small.gif" width="9" height="9"><font   style="font-size:14px;font-family:MSYHBD;"><a href="#" onclick="sava()">存储</a></font>&nbsp;&nbsp;</span>
      <span><img src="/Sunlike/images/arrow_r_r_small.gif" width="9" height="9"><font   style="font-size:14px;font-family:MSYHBD;">修改紀錄</font>&nbsp;&nbsp;</span>
      </div></td>
    </tr></tbody>
</table>
  

<table width="98%" cellspacing="0" cellpadding="6" rules="groups" align="center">
    <thead> 
    <tr bgcolor="#ECE8D8" >
      <td width="4%"><div align="center"><font style="font-size:16px;font-family:MSYHBD;"><span>No.</span></font></div></td> 
      <td> 
        <div align="center"><font color="black" style="font-size:16px;font-family:MSYHBD;"><span>職稱</span></font></div>
      </td>
      <td> 
        <div align="left"><font color="black" style="font-size:16px;font-family:MSYHBD;"><span>姓名/部門</span></font></div>
      </td>
      <td align="left"><font color="black" style="font-size:16px;font-family:MSYHBD;"><span>權限&nbsp;&nbsp;</span></font></td>
      </tr>
    </thead> 
    
    <%
    	int i =1;
    	for(SALM  salm : salms){
    		String SAL_NO = salm.getSAL_NO();
     %>
    <tbody> 
    <tr>
      <td align="center" ><span><%= i++ %><b>.</b></span></td> 
      <td> 
        <div align="center"><span><font color="black" style="font-size:16px;font-family:MSYHBD;"><%= salm.getPOS() %></font></span></div>
      </td>
      <td> 
        <div align="left"><span> 
          <input type="hidden" name="adrbok_id" value="GT8888">
          <font  style="font-size:16px;font-family:MSYHBD;" color="blue"><%= salm.getNAME() %>/<%= salm.getDEP()!=null?salm.getDEP().getNAME():"<font color='red'>未設置部門</font>" %></font> 
         </span></div>
      </td>
      <td align="left"><span>
           <input id="new_<%= SAL_NO  %>" type="checkbox"  <%= JobPriviledgeUtil.isChecked(SAL_NO, pajobpriviledges, "PNEW") %> value="<%= SAL_NO  %>" class="checkall">
           		<font color="black" style="font-size:16px;font-family:MSYHBD;">新增</font>&nbsp;&nbsp;
           <input id="remove_<%= SAL_NO  %>"  type="checkbox"  <%= JobPriviledgeUtil.isChecked(SAL_NO, pajobpriviledges, "PREMOVE") %> value="<%= SAL_NO  %>">
           		<font color="black" style="font-size:16px;font-family:MSYHBD;">刪除</font>&nbsp;&nbsp;
           <input id="view_<%= SAL_NO  %>" type="checkbox"  <%=JobPriviledgeUtil.isChecked(SAL_NO, pajobpriviledges, "PVIEW")    %> value="<%= SAL_NO  %>" >
           		<font color="black" style="font-size:16px;font-family:MSYHBD;">查詢</font>&nbsp;&nbsp;
           <input id="modify_<%= SAL_NO  %>"  type="checkbox"  <%= JobPriviledgeUtil.isChecked(SAL_NO, pajobpriviledges, "PMODIFY")    %> value="<%= SAL_NO  %>" >
           		<font color="black" style="font-size:16px;font-family:MSYHBD;">修改</font>&nbsp;&nbsp;
           <input id="privacy_<%= SAL_NO  %>" type="checkbox"  <%=JobPriviledgeUtil.isChecked(SAL_NO, pajobpriviledges, "PRIVACY")%> value="<%= SAL_NO  %>" >
           		<font color="black" style="font-size:16px;font-family:MSYHBD;">機密</font>&nbsp;&nbsp;
           <input id="sava_<%= SAL_NO  %>" type="checkbox"  <%=JobPriviledgeUtil.isChecked(SAL_NO, pajobpriviledges, "PSAVA")  %> value="<%= SAL_NO  %>" >
           		<font color="black" style="font-size:16px;font-family:MSYHBD;">另存為</font>
      </span></td>
      </tr>
    </tbody> 
   <%
    	}
   %>
</table>
<br>
</body>
</html>